import request from '@/utils/request'

// 新增菜单
export const createMenu = (data) => request({
  url: '/admin/menu',
  method: 'post',
  data
})

// 删除菜单
export const deleteMenu = (data) => request({
  url: '/admin/menu',
  method: 'delete',
  data
})

// 修改菜单
export const updateMenu = (data) => request({
  url: '/admin/menu',
  method: 'put',
  data
})

// 单个查询菜单
export const queryMenu = (menuId) => request({
  url: '/admin/menu',
  method: 'get',
  params: { menuId }
})

// 分页查询菜单
export const pageQuery = (data) => request({
  url: '/admin/menu/page',
  method: 'post',
  data
})

// 使菜单隐藏/显示
export const changeHidden = (id, hidden) => request({
  url: '/admin/menu/changeHidden',
  method: 'put',
  params: { id, hidden }
})

// 构建菜单
export const bulidMenu = () => request({
  url: '/admin/menu/bulid',
  method: 'get'
})

// 获取当前用户所有权限
export const getPermissionsByUser = () => request({
  url: '/admin/menu/permissions',
  method: 'get'
})
